package com.zyh.mapper;


import com.zyh.entity.*;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface Usermapper {


    //根据用户名密码查询用户信息
    @Select("Select * FROM t_user WHERE account=#{account} and password=#{password}")
    public User selectUserBypwd(User user);

    //查询所有的用户
    List<User> getAllUser(UserVO userVO);

    //根据id查询用户信息
    @Select("Select * FROM t_user WHERE id=#{id}")
    public User selectUser(Integer id);

    //修改用户信息
    public Integer updateUserWithId(User user);


    //添加用户
    @Insert("INSERT INTO t_user (account,username,email,password,telephonenumber,sex,valid) " +
            "VALUES (#{account},#{username},#{email},#{password},#{telephonenumber},#{sex},#{valid})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    public Integer addUser(User user);


    //多条件查询
    public List<User> selectBywhere(User user);

    //统计用户数量
    public Integer getUserCount(UserVO userVO);

    //删除用户
    public Integer DeleteUserByids(Integer[] id);

    //删除书
    public Integer DeleteBookByids(Integer[] id);


    //修改开关
    @Update("update t_user set enable=#{enable} where id=#{id}")
    public Integer updateenable(User user);


    //修改个人信息
    public Integer updatemyself(User user);


    //修改头像
    public Integer updatephotos(User user);

    public List<Province> getProvince();

    public List<City> getCity(String code);

    public List<Area> getArea(String code);
}
